package day03;

import java.util.Scanner;

public class HomeWork03 {
    public static void main(String[] args) {
        /*
        1. 运算符的练习：算术
           - 输出几个整数取模，验证结果
           - 声明两个整型变量，演示单独使用时的自增和自减
           - 声明几个整型变量，演示被使用时的自增和自减*/
        System.out.println(24 % 5);
        System.out.println(35 % 3);
        System.out.println(2 % 7);

        int a = 8, b = 56;
        a++;
        b++;
        System.out.println(a);
        System.out.println(b);
        ++a;
        ++b;
        System.out.println(a);
        System.out.println(b);
        a--;
        b--;
        System.out.println(a);
        System.out.println(b);
        --a;
        --b;
        System.out.println(a);
        System.out.println(b);

        int c = 5, d = 6;
        int e = c++;
        System.out.println(e);
        e = d++;
        System.out.println(e);

        int f = c--;
        System.out.println(f);
        f = d--;
        System.out.println(f);
        int g = --c;
        System.out.println(g);
        g = --d;
        System.out.println(g);

           /*2. 运算符的练习：关系
             - 声明几个变量，演示最基本的>，<，>=，<=，==，!=操作
             - 演示关系运算符和算术运算符联合使用的效果
            */
        int aa = 67, bb = 8, cc = 89;
        boolean dd = aa > bb;
        System.out.println(dd);
        System.out.println(aa > cc);
        System.out.println(cc >= aa);
        System.out.println(cc = aa);

        System.out.println(aa + bb > cc);
        System.out.println(cc % aa == bb);
        System.out.println(aa * bb == cc);

        int aa1 = 67, bb1 = 8, cc1 = 89;
        boolean dd1 = aa1> bb1;
        System.out.println(dd1);
        System.out.println(aa1 > cc1);
        System.out.println(cc1 >= aa1);
        System.out.println(cc1 = aa1);

        System.out.println((aa1 + bb1) > cc1);
        System.out.println(cc1 % aa1 == bb1);
        System.out.println(aa1 * bb1 == cc1);
           /*
            3. 运算符的练习：逻辑
            - 声明三个整型变量，演示&&和||，演示!
            - &&的演示要求：true+false、false+true、true+true、false+false
            - ||的演示要求：true+false、false+true、true+true、false+false
            - !的演示要求：true、false
            - 演示短路&&与短路||
            */
        int ee = 23, ff = 45, gg = 56;
        boolean h = ee < ff && ff > gg;
        System.out.println(h);
        h = ee > ff && ff < gg;
        System.out.println(h);
        h = ee < ff & ff < gg;
        System.out.println(h);
        System.out.println(ee > ff && ff > gg);

        System.out.println(ee < ff || ff > gg);
        System.out.println(ee > ff || ff < gg);
        System.out.println(ee < ff || ff < gg);
        System.out.println(ee > ff || ff > gg);

        boolean hh = ee > ff;
        System.out.println(!h);
        System.out.println(h);

        int a1 = 3;
        System.out.println(ee > ff && a1++ == 3);
        System.out.println(a1);
        System.out.println(ee < ff || a1++ > gg);

        int ee1 = 231, ff1 = 451, gg1 = 516;
        boolean h1 = ee1 < ff1 && ff1 > gg1;
        System.out.println(h1);
        h1 = ee1 > ff1 && ff1 < gg1;
        System.out.println(h1);
        h1 = ee1 < ff1 & ff1 < gg1;
        System.out.println(h1);
        System.out.println(ee1 > ff1 && ff1 > gg1);

        System.out.println(ee1 < ff1 || ff1 > gg1);
        System.out.println(ee1 > ff1 || ff1 < gg1);
        System.out.println(ee1 < ff1 || ff1 < gg1);
        System.out.println(ee1 > ff1 || ff1 > gg1);

        boolean hh1 = ee1 > ff1;
        System.out.println(!hh1);
        System.out.println(hh1);

        int a11 = 3;
        System.out.println(ee1 > ff1 && a11++ == 3);
        System.out.println(a11);
        System.out.println(ee1 < ff1 || a11++ > gg);

           /*4. 运算符的练习：赋值
           - 声明一个整型变量，演示扩展赋值+=、-=、*=、/=、%=的效果
           - 声明short型变量s，演示简单赋值运算的自增10，演示扩展赋值运算的自增10
            */

        int jj = 45;
        System.out.println(jj += 34);
        System.out.println(jj -= 34);
        System.out.println(jj *= 56);
        System.out.println(jj /= 67);
        System.out.println(jj %= 3);
        short s = 56;
        System.out.println(s += 10);
        s = (short) (s + 10);
        System.out.println(s);

        jj=56;
        System.out.println(jj+=67);
        System.out.println(jj -= 78);
        System.out.println(jj *= 545);
        System.out.println(jj /= 647);
        System.out.println(jj %= 13);
        s = 567;
        System.out.println(s += 110);
        s = (short) (s + 110);
        System.out.println(s);

           /*
           5. 运算符的练习：字符串连接
           - 声明整型变量age和字符串型变量name，输出字符串连接的结果
           - 输出几个数据的拼接，演示字符串连接的同化作用
            */
        int age = 56;
        String name = "ssl";
        System.out.println(name + age);
        System.out.println("ssl:" + age);
        System.out.println("name:" + name + ",年龄：" + age);
        System.out.println(age + "年龄");
        System.out.println(10 + 20 + "" + 30);
        System.out.println("" + 10 + 20 + 30);
        System.out.println(10 + 20 + 30 + "");

           /*
             6. 运算符的练习：条件/三目
           - 声明并初始化整型变量，使用条件运算符实现：若>0则给flag赋值为1，否则赋值为0
           - 声明两个整型变量，使用条件运算符实现：求这两个变量的最大值
            */
        int r = 4, ss = 5;
        int flag = r > 0 ? 1 : 0;
        System.out.println(flag);
        flag = r > ss ? r : ss;
        System.out.println(flag);

        int r1 = 43, ss1 = 45;
        flag = r1 > 0 ? 1 : 0;
        System.out.println(flag);
        flag = r1 > ss ? r1 : ss;
        System.out.println(flag);

        int rr=6,tt=7;
        flag=rr>tt?1:0;
        System.out.println(flag);

           /*7. 分支结构的练习：if
           - 满500打8折
           - 判断成绩是否合法
            */
        double price = 5000;
        if (price >= 500) {
            price *= 0.8;
        } else ;
        System.out.println(price);
        double score = 80;
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法" + score);
        }

        price = 675;
        if (price > 500) {
            price *= 0.8;
        }
        System.out.println(price);
        score = 56;
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法" + score);
        }
           /*
            8. 分支结构的练习：if...else
           - 满500打8折，不满500打9折
           - 判断成绩合法还是不合法
            */
        price = 674;
        if (price > 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        score = 67;
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法" + score);
        } else {
            System.out.println("成绩不合法" + score);
        }

        price = 67879;
        if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        score = 898;
        if (score >= 0 && score <= 100) {
            System.out.println("成绩合法" + score);
        } else {
            System.out.println("成绩不合法" + score);
        }

           /*
           9. 分支结构的练习：if...else if
           - 满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折
            */
        price = 4356;
        if (price >= 2000) {
            price *= 0.5;
        } else if (price >= 1000) {
            price *= 0.7;
        } else if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        System.out.println("消费总额：" + price);

        price = 57690;
        if (price >= 2000) {
            price *= 0.5;
        } else if (price >= 1000) {
            price *= 0.7;
        } else if (price >= 500) {
            price *= 0.8;
        } else {
            price *= 0.9;
        }
        System.out.println("消费总额：" + price);

           /*
           10. 分支结构的练习：switch...case结构
           - CommandBySwitch命令解析程序：
           要求：接收用户输入的命令，依据命令做不同的操作
            */

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入需要的业务办理编号： 1.存款  2.取款 3.查询余额  4.exit(退出)");
        int command = scan.nextInt();
        switch (command) {
            case 1: {
                System.out.println("存款业务办理中,请等待....");
            }
            case 2: {
                System.out.println("取款业务办理中,请等待....");
            }
            case 3: {
                System.out.println("查询业务办理中,请等待....");
            }
            case 4: {
                System.out.println("业务办理退出中,请等待....");
            }
            default:
                System.out.println("输入错误，请重新输入");
        }


        Scanner scan1 = new Scanner(System.in);
        System.out.println("请输入业务流程编码：");
        int num = scan1.nextInt();
        switch (num) {
            case 1: {
                System.out.println("存款业务办理中");
                break;
            }
            case 2: {
                System.out.println("借款业务办理中");
                break;
            }
            case 3: {
                System.out.println("远程扫描启动中");
                break;
            }
            case 4: {
                System.out.println("exit退出中，请稍后拔卡");
                break;
            }


        }


    }}
